﻿using System;

namespace ExpressesClass.SfApi.Util
{
    public class CallExpressServiceTools
    {
        private class Nested
        {
            internal static CallExpressServiceTools tools;
            static Nested()
            {
                tools = null;
                tools = new CallExpressServiceTools();
            }
        }
        private CallExpressServiceTools()
        {
        }
        public static CallExpressServiceTools getInstance()
        {
            return CallExpressServiceTools.Nested.tools;
        }
        public string callSfExpressServiceByCSIM(string reqURL, string reqXML, string checkword)
        {
            string verifyCode = VerifyCodeUtil.md5EncryptAndBase64(reqXML + checkword);
            return querySFAPIservice(reqURL, reqXML, verifyCode);
        }
        public static string querySFAPIservice(string url, string xml, string verifyCode)
        {
            HttpClientUtil httpClientUtil = new HttpClientUtil();
            if (url == null)
            {
                url = "http://bsp-oisp.sf-express.com/bsp-oisp/sfexpressService";
            }
            try
            {
                return httpClientUtil.postSFAPI(url, xml, verifyCode);
            }
            catch (Exception ex)
            {
                Console.Write(ex.StackTrace);
            }
            return null;
        }
    }
}
